<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      #box {
        width: 200px;
        height: 200px;
        margin: auto;
        background-color: black;
        color: #fff;
        box-sizing: border-box;
        padding: 30px;
        cursor: crosshair;
      }
    </style>
  </head>
  <body>
    <div id="box" onmouseout="chaa()" onmouseover="cha()">鼠标移入改变样式，鼠标移出恢复</div>
  </body>
</html>
<script>
  var dom = document.getElementById("box");
  function cha() {
    dom.style.cssText =" box-sizing: border-box;padding: 0px; border: 30px #f00 solid; color: #f00;background-color: #fff;";
  }
  function chaa() {
    dom.style.cssText =
      " box-sizing: border-box;  color: #fff;background-color: #000;";
  }
</script>
